# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=cliff
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=4.10.0
pkgrel=1
pkgdesc="Command Line Interface Formulation Framework (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-cliff'
  'purl: pkg:pypi/cliff'
)
msys2_repository_url='https://opendev.org/openstack/cliff/'
msys2_documentation_url='https://docs.openstack.org/cliff/latest/'
msys2_issue_tracker_url='https://launchpad.net/python-openstackclient/'
url='https://docs.openstack.org/cliff/latest/'
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python-autopage"
         "${MINGW_PACKAGE_PREFIX}-python-cmd2"
         "${MINGW_PACKAGE_PREFIX}-python-prettytable"
         "${MINGW_PACKAGE_PREFIX}-python-stevedore"
         "${MINGW_PACKAGE_PREFIX}-python-yaml")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-pbr"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
#checkdepends=("${MINGW_PACKAGE_PREFIX}-python-testrepository"
#              "${MINGW_PACKAGE_PREFIX}-python-mock"
#              "${MINGW_PACKAGE_PREFIX}-python-sphinx"
#              "${MINGW_PACKAGE_PREFIX}-python-oslosphinx"
#              "${MINGW_PACKAGE_PREFIX}-python-testscenarios")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('8c1f5b682741a03b0c4607c82e8af41d4e9c2859024646562f86cdeb2959a86d')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"

  # Set version for pbr
  export PBR_VERSION=${pkgver}
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

#check() {
#  msg "Python test for ${MSYSTEM}"
#  cd "${srcdir}/python-build-${MSYSTEM}"
#  PYTHON=${MINGW_PREFIX}/bin/python3 \
#     ${MINGW_PREFIX}/bin/python setup.py testr
#}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
